<?php

namespace app\store\controller\form;

use app\store\controller\Controller;
use app\store\model\WxappPage as WxappPageModel;


/**
 * 自定义表单管理
 * Class Coupon
 * @package app\store\controller\market
 */
class Info extends Controller
{
    /* @var CouponModel $model */
    private $model;

    /**
     * 构造方法
     * @throws \app\common\exception\BaseException
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function _initialize()
    {
        parent::_initialize();
    }

    /**
     * 表单列表
     * @return mixed
     * @throws \think\exception\DbException
     */
    public function index()
    {
        $model = new WxappPageModel;
        $wxapp_id = $model::$wxapp_id;
       
        $list = db('custom_form')->order('id desc')->where('wxapp_id',$wxapp_id)->select();
        return $this->fetch('index', [
            'list' => $list
        ]);
    }
    
    /**
     * 表单详情
     * @return mixed
     * @throws \think\exception\DbException
     */
    public function detail()
    {
        $id = input('id','');
        $one = db('custom_form')->where('id',$id)->find();
        $field = $one['field'];
        $field = explode('_', $field);
        
        return $this->fetch('detail', [
            '$one' => $one,
            'field' => $field
        ]);
        // $model = new WxappPageModel;
        // $wxapp_id = $model::$wxapp_id;
       
        // $list = db('custom_form')->order('id desc')->where('wxapp_id',$wxapp_id)->select();
        // return $this->fetch('index', [
        //     'list' => $list
        // ]);
    }
}